from UserSettingsPage import UserSettingsPage
from Autotests.LocalMachine.Controls.Button import WebButton
from Autotests.LocalMachine.Controls.Label import WebLabel
from Autotests.LocalMachine.UiObjectsMap.AirManager import UserSettings
from Autotests.WebDriver import DRIVER


class SupportTab(UserSettingsPage):
    def __init__(self):
        super(SupportTab, self).__init__()

    def goToHomeLocation(self):
        super(SupportTab, self).goToHomeLocation()
        WebButton(UserSettings.btnSupport).click()

    def _goToLink(self, link):
        self.goToHomeLocation()
        link.click()
        DRIVER().switch_to_window(DRIVER().window_handles[-1])

    def linkFaqClick(self):
        self._goToLink(WebLabel(UserSettings.Support.linkFAQ))

    def isFaqPageActive(self):
        return "center" in DRIVER().current_url

    def linkSubmitTicketClick(self):
        self._goToLink(WebLabel(UserSettings.Support.linkSubmitTicket))

    def ifSubmitTicketPageActive(self):
        return "request" in DRIVER().current_url
